


(function(){
  function loadExternalResource(url, type,callback) {
    var tag;
    if (type === 'css') {
      tag = document.createElement('link');
      tag.rel = 'stylesheet';
      tag.href = url;
    }
    else if (type === 'js') {
      tag = document.createElement('script');
      tag.src = url;
    }
    if (tag) {
      tag.onload = function(){if(callback){callback(true)}};
      tag.onerror = function(){if(callback){callback(false)}};
      document.head.appendChild(tag);
    }
  }
  loadExternalResource('./css/waifu.css','css',function(){
    loadExternalResource('./lib/cubism2/live2d.min.js', 'js',function(){
      loadExternalResource('./lib/cubism5/live2dcubismcore.min.js', 'js',function(){
        loadExternalResource('./js/index.umd.js', 'js',function(){
          initWidget({
            waifuPath: './json/waifu-tips.json',
            cubism2Path: './lib/cubism2/live2d.min.js',
            cubism5Path: './lib/cubism5/live2dcubismcore.min.js',
            tools: ['hitokoto', 'asteroids', 'switch-model', 'switch-texture', 'photo', 'info', 'quit'],
            logLevel: 'warn',
            drag: true,
          });
        })
      })
    })
  })
})();
